<?php require('connections/con_gl.php'); ?>
<?php
cekAkses($_SESSION[akses],"MS-8-2");
mysql_select_db($database_con_gl, $con_gl);
$query_klas6 = "SELECT id, jenis FROM gl_jenisasuransi ORDER BY jenis ASC";
$klas6 = mysql_query($query_klas6, $con_gl) or die(mysql_error());
$row_klas6 = mysql_fetch_assoc($klas6);
$totalRows_klas6 = mysql_num_rows($klas6);

mysql_select_db($database_con_gl, $con_gl);
$query_klas10 = "SELECT id, jenisbbm FROM gl_jenisbbm ORDER BY jenisbbm ASC";
$klas10 = mysql_query($query_klas10, $con_gl) or die(mysql_error());
$row_klas10 = mysql_fetch_assoc($klas10);
$totalRows_klas10 = mysql_num_rows($klas10);

$colname_edit = "-1";
if (isset($_GET['id'])) {
  $colname_edit = (get_magic_quotes_gpc()) ? $_GET['id'] : addslashes($_GET['id']);
}
mysql_select_db($database_con_gl, $con_gl);
$query_edit = sprintf("SELECT * FROM gl_masterkendaraan WHERE id = %s", $colname_edit);
$edit = mysql_query($query_edit, $con_gl) or die(mysql_error());
$row_edit = mysql_fetch_assoc($edit);
$totalRows_edit = mysql_num_rows($edit);

mysql_select_db($database_con_gl, $con_gl);
$query_klas4 = "SELECT id, gudang FROM gl_gudang where area='$row_edit[area]' ORDER BY gudang ASC";
$klas4 = mysql_query($query_klas4, $con_gl) or die(mysql_error());
$row_klas4 = mysql_fetch_assoc($klas4);
$totalRows_klas4 = mysql_num_rows($klas4);

?>
<link href="ccss/ui.datepicker.css" type="text/css" rel="stylesheet" />
<script type="text/javascript" src="js/ui.datepicker.js"></script>
<script type="text/javascript">
// --- cek status kir
function checkstatuskir(val) {
	if(val=='NONE') {
		document.getElementById('nokir').value=null;	
		document.getElementById('nokir').disabled='disabled';		
		document.getElementById('jthtempokir').value=null;	
		document.getElementById('jthtempokir').disabled='disabled';		
	}else{
		document.getElementById('nokir').disabled='';	
		document.getElementById('jthtempokir').disabled='';	
	}
}
// --- cek status asuransi
function checkstatusasuransi(val) {
	if(val=='NONE') {
		document.getElementById('jenisasuransi').value=null;	
		document.getElementById('jenisasuransi').disabled='disabled';		
		document.getElementById('namaperusahaan').value=null;	
		document.getElementById('namaperusahaan').disabled='disabled';		
		document.getElementById('nopolis').value=null;	
		document.getElementById('nopolis').disabled='disabled';		
		document.getElementById('jthtempopolis').value=null;	
		document.getElementById('jthtempopolis').disabled='disabled';		
	}else{
		document.getElementById('jenisasuransi').disabled='';	
		document.getElementById('txtnamaperusahaan').disabled='';	
		document.getElementById('nopolis').disabled='';	
		document.getElementById('jthtempopolis').disabled='';	
	}
}
<!--
$(function()
      {
        $('.calendar').datepicker({
            appendText : "",
            dateFormat : 'yy/mm/dd'
          });
      });
	  
</script>
<script type="text/javascript" src="js/ajax_data.js"></script>
<script type="text/javascript">
$(document).ready(function() {

	$().ajaxStart(function() {
		$('#loading').show();
		$('#result').hide();
	}).ajaxStop(function() {
		$('#loading').hide();
		$('#result').fadeIn('slow');
	});

	$('#edit').submit(function() {
		$.ajax({
			type: 'POST',
			url: $(this).attr('action'),
			data: $(this).serialize(),
			success: function(data) {
				$('#result').html(data);
			}
		})
		return false;
	});
  $('#result').click(function(){
  $(this).hide();
  });
})
</script>
<div id="loading" style="display:none;"><img src="images/loading.gif" alt="loading..." /></div>
<div id="result" style="display:none;"></div>
<h1>Lihat Data Stok Kendaraan</h1>
<form action="proses/masterkendaraan.php?act=edit" method="POST" name="edit" id="edit" >
  <table width="100%" border="0" align="center" cellpadding="5" cellspacing="0">
    <tr>
      <td colspan="2" align="right" bgcolor="#DDDDDD"><div align="left">Data Umum Kendaraan</div></td>
      <td width="1%" bgcolor="#FFFFFF">&nbsp;</td>
      <td colspan="2" bgcolor="#DDDDDD">Data Surat-Surat Kendaraan</td>
      <td width="1%" bgcolor="#FFFFFF">&nbsp;</td>
      <td colspan="3" bgcolor="#DDDDDD">Data Operasional </td>
    </tr>
    <tr>
      <td width="12%" align="right" valign="top" bgcolor="#FFFFFF">Kode Asset </td>
      <td bgcolor="#FFFFFF"><?php echo $row_edit['kodeasset']; ?></td>
      <td bgcolor="#FFFFFF">&nbsp;</td>
      <td width="13%" bgcolor="#EEEEEE"><div align="left">STNK </div></td>
      <td width="20%" bgcolor="#FFFFFF">&nbsp;</td>
      <td bgcolor="#FFFFFF">&nbsp;</td>
      <td width="13%" bgcolor="#FFFFFF"><div align="right">Nama Pengemudi : </div></td>
      <td colspan="2" bgcolor="#FFFFFF"><input type="hidden" name="namapengemudi" id="namapengemudi" value="<?php echo $row_edit['pengemudi']; ?>" />
        <?php list($pengemudi) = mysql_fetch_row(mysql_query("select nama from gl_kontak where id = '$row_edit[pengemudi]'"));?>
        <?php echo $pengemudi; ?></td>
    </tr>
    <tr>
      <td width="12%" align="right" valign="top" bgcolor="#FFFFFF">No.Polisi*  : </td>
      <td bgcolor="#FFFFFF"><?php echo $row_edit['nopolisi']; ?></td>
      <td bgcolor="#FFFFFF">&nbsp;</td>
      <td valign="top" bgcolor="#FFFFFF"><div align="right">Atas Nama : </div></td>
      <td bgcolor="#FFFFFF"><?php echo $row_edit['namapemilik']; ?></td>
      <td bgcolor="#FFFFFF">&nbsp;</td>
      <td bgcolor="#FFFFFF"><div align="right">Nama Pelanggan : </div></td>
      <td colspan="2" bgcolor="#FFFFFF"><input type="hidden" name="namacustomer" id="namacustomer" value="<?php echo $row_edit['namacustomer']; ?>" />
        <?php list($namacustomer) = mysql_fetch_row(mysql_query("select nama from gl_kontak where id = '$row_edit[namacustomer]'"));?>
        <?php echo $namacustomer; ?></td>
    </tr>
    <tr>
      <td align="right" valign="top" bgcolor="#FFFFFF">Jenis Kendaraan : </td>
      <td bgcolor="#FFFFFF">
	  <!-- Added by suwondo -->
	  <input type="hidden" name="jeniskendaraan" id="jeniskendaraan" value="<?php echo $row_edit['jeniskendaraan']; ?>" />
	  <?php list($namajenis) = mysql_fetch_row(mysql_query("select jeniskendaraan from gl_jeniskendaraan where id = '$row_edit[jeniskendaraan]'"));?>
	  <?php echo $namajenis; ?></td>
      <td bgcolor="#FFFFFF">&nbsp;</td>
      <td valign="top" bgcolor="#FFFFFF"><div align="right">No. STNK* : </div></td>
      <td bgcolor="#FFFFFF"><?php echo $row_edit['nostnk']; ?></td>
      <td bgcolor="#FFFFFF">&nbsp;</td>
      <td bgcolor="#FFFFFF"><div align="right">Jatuh Tempo Sewa :</div></td>
      <td colspan="2" bgcolor="#FFFFFF"><?php echo $row_edit['jthtemposewa']; ?></td>
    </tr>
    <tr>
      <td align="right" valign="top" bgcolor="#FFFFFF">Merk Kendarran : </td>
      <td bgcolor="#FFFFFF">
	  <!-- Added by suwondo -->
	  <input type="hidden" name="merk" id="merk" value="<?php echo $row_edit['merk']; ?>" />
	  <?php list($namamerk) = mysql_fetch_row(mysql_query("select merk from gl_merkkendaraan where id = '$row_edit[merk]'"));?>
	  <?php echo $namamerk; ?></td>
      <td bgcolor="#FFFFFF">&nbsp;</td>
      <td valign="top" bgcolor="#FFFFFF"><div align="right">Jatuh Tempo STNK* : </div></td>
      <td bgcolor="#FFFFFF"><?php echo $row_edit['jthtempostnk']; ?></td>
      <td bgcolor="#FFFFFF">&nbsp;</td>
      <td bgcolor="#FFFFFF"><div align="right">KM Awal  : </div></td>
      <td colspan="2" bgcolor="#FFFFFF"><?php echo $row_edit['kmawal']; ?> - KM Akhir :
        <?php echo $row_edit['kmakhir']; ?></td>
    </tr>
    <tr>
      <td align="right" valign="top" bgcolor="#FFFFFF">Tipe Kendaraan : </td>
      <td bgcolor="#FFFFFF">
	  <!-- Added by suwondo -->
	  <input type="hidden" name="tipekendaraan" id="tipekendaraan" value="<?php echo $row_edit['tipekendaraan']; ?>" />
	  <?php list($namatype) = mysql_fetch_row(mysql_query("select tipekendaraan from gl_tipekendaraan where id = '$row_edit[tipekendaraan]'"));?>
	  <?php echo $namatype; ?></td>
      <td bgcolor="#FFFFFF">&nbsp;</td>
      <td valign="top" bgcolor="#FFFFFF"><div align="right">No BPKB* : </div></td>
      <td bgcolor="#FFFFFF"><?php echo $row_edit['nobpkb']; ?></td>
      <td bgcolor="#FFFFFF">&nbsp;</td>
      <td colspan="3" bgcolor="#DDDDDD">Kelengkapan Kendaraan</td>
    </tr>
    <tr>
      <td align="right" valign="top" bgcolor="#FFFFFF">Tahun Pembuatan : </td>
      <td bgcolor="#FFFFFF"><?php echo $row_edit['tahun']; ?></td>
      <td bgcolor="#FFFFFF">&nbsp;</td>
      <td valign="top" bgcolor="#FFFFFF"><div align="right">No. Mesin* : </div></td>
      <td bgcolor="#FFFFFF"><?php echo $row_edit['nomesin']; ?></td>
      <td bgcolor="#FFFFFF">&nbsp;</td>
      <td valign="top" bgcolor="#FFFFFF"><input name="ban" type="checkbox" id="ban" value="ok" <?php if(strstr($row_edit['ban'],"ok")) { ?>checked="checked"<?php } ?>/>
        Ban Cadangan </td>
      <td width="6%" valign="top" bgcolor="#FFFFFF">&nbsp;</td>
      <td width="14%" valign="top" bgcolor="#FFFFFF"><input name="radiotape" type="checkbox" id="radiotape" value="ok" <?php if(strstr($row_edit['radiotape'],"ok")) { ?>checked="checked"<?php } ?>/>
      Radio Tape </td>
    </tr>
    <tr>
      <td align="right" valign="top" bgcolor="#FFFFFF">Warna Utama : </td>
      <td bgcolor="#FFFFFF"><?php echo $row_edit['warnautama']; ?></td>
      <td bgcolor="#FFFFFF">&nbsp;</td>
      <td valign="top" bgcolor="#FFFFFF"><div align="right">No. Rangka* : </div></td>
      <td bgcolor="#FFFFFF"><?php echo $row_edit['norangka']; ?></td>
      <td bgcolor="#FFFFFF">&nbsp;</td>
      <td valign="top" bgcolor="#FFFFFF"><input name="dongkrak" type="checkbox" id="dongkrak" value="ok" <?php if(strstr($row_edit['dongkrak'],"ok")) { ?>checked="checked"<?php } ?>/>
        Dongkrak</td>
      <td valign="top" bgcolor="#FFFFFF">&nbsp;</td>
      <td valign="top" bgcolor="#FFFFFF"><input name="karpet" type="checkbox" id="karpet" value="ok" <?php if(strstr($row_edit['karpet'],"ok")) { ?>checked="checked"<?php } ?>/>
        Karpet Lantai </td>
    </tr>
    <tr>
      <td align="right" valign="top" bgcolor="#FFFFFF">Warna Kombinasi : </td>
      <td bgcolor="#FFFFFF"><?php echo $row_edit['warnakomb']; ?></td>
      <td bgcolor="#FFFFFF">&nbsp;</td>
      <td valign="top" bgcolor="#EEEEEE">Asuransi Kendaraan </td>
      <td bgcolor="#FFFFFF">&nbsp;</td>
      <td bgcolor="#FFFFFF">&nbsp;</td>
      <td valign="top" bgcolor="#FFFFFF"><input name="segitiga" type="checkbox" id="segitiga" value="ok" <?php if(strstr($row_edit['segitiga'],"ok")) { ?>checked="checked"<?php } ?>/>
        Segitiga Pengaman </td>
      <td valign="top" bgcolor="#FFFFFF">&nbsp;</td>
      <td valign="top" bgcolor="#FFFFFF"><input name="doproda" type="checkbox" id="doproda" value="ok" <?php if(strstr($row_edit['doproda'],"ok")) { ?>checked="checked"<?php } ?>/>
        Dop Roda </td>
    </tr>
    <tr>
      <td align="right" valign="top" bgcolor="#FFFFFF">Jenis BBM : </td>
      <td bgcolor="#FFFFFF">
	  <?php list($jenisbbm) = mysql_fetch_row(mysql_query("select jenisbbm from gl_jenisbbm where id='$row_edit[jenisbbm]'")); echo $jenisbbm; ?>	  </td>
      <td bgcolor="#FFFFFF">&nbsp;</td>
      <td valign="top" bgcolor="#FFFFFF"><div align="right">Status Asuransi : </div></td>
      <td bgcolor="#FFFFFF"><?php echo $row_edit['statusasuransi']; ?></td>
      <td bgcolor="#FFFFFF">&nbsp;</td>
      <td valign="top" bgcolor="#FFFFFF"><input name="kunciroda" type="checkbox" id="kunciroda" value="ok" <?php if(strstr($row_edit['kunciroda'],"ok")) { ?>checked="checked"<?php } ?>/>
        Kunci Roda </td>
      <td valign="top" bgcolor="#FFFFFF">&nbsp;</td>
      <td valign="top" bgcolor="#FFFFFF"><input name="pematikapi" type="checkbox" id="pematikapi" value="ok" <?php if(strstr($row_edit['pematikapi'],"ok")) { ?>checked="checked"<?php } ?>/>
        Pematik Api </td>
    </tr>
    <tr>
      <td align="right" valign="top" bgcolor="#FFFFFF">Est. Rasio BBM : </td>
      <td bgcolor="#FFFFFF"><?php echo $row_edit['rasio']; ?>
        KM/Liter</td>
      <td bgcolor="#FFFFFF">&nbsp;</td>
      <td valign="top" bgcolor="#FFFFFF"><div align="right">Jens Polis : </div></td>
      <td bgcolor="#FFFFFF"><?php if($row_klas6['id']==$row_edit['jenisasuransi']);?></td>
	  
      <td bgcolor="#FFFFFF">&nbsp;</td>
      <td valign="top" bgcolor="#FFFFFF">&nbsp;</td>
      <td colspan="2" valign="top" bgcolor="#FFFFFF">&nbsp;</td>
    </tr>
    <tr>
      <td align="right" valign="top" bgcolor="#FFFFFF">Jumlah seat : </td>
      <td bgcolor="#FFFFFF"><?php echo $row_edit['jmlseat']; ?></td>
      <td bgcolor="#FFFFFF">&nbsp;</td>
      <td valign="top" bgcolor="#FFFFFF"><div align="right">Perusahaan Asuransi : </div></td>
      <td bgcolor="#FFFFFF"><label><input type="hidden" name="namaperusahaan" id="namaperusahaan" value="<?php echo $row_edit['namaperusahaan']; ?>" />
        <?php list($namaperusahaan) = mysql_fetch_row(mysql_query("select nama from gl_kontak where id = '$row_edit[namaperusahaan]'"));?>
        <?php echo $namaperusahaan; ?></label></td>
      <td bgcolor="#FFFFFF">&nbsp;</td>
      <td>&nbsp;</td>
      <td colspan="2">&nbsp;</td>
    </tr>
    <tr>
      <td colspan="2" bgcolor="#DDDDDD">Status Kendaraan</td>
      <td bgcolor="#FFFFFF">&nbsp;</td>
      <td valign="top" bgcolor="#FFFFFF"><div align="right">No.Polis : </div></td>
      <td bgcolor="#FFFFFF"><?php echo $row_edit['nopolis']; ?></td>
      <td bgcolor="#FFFFFF">&nbsp;</td>
      <td valign="top" bgcolor="#FFFFFF">&nbsp;</td>
      <td colspan="2" valign="top" bgcolor="#FFFFFF">&nbsp;</td>
    </tr>
    <tr>
      <td width="12%" bgcolor="#FFFFFF"><div align="right">Area : </div></td>
      <td width="20%" bgcolor="#FFFFFF">
	  <?php
		if(!strstr($_SESSION[akses],'A-1-4')) {	
		 /* Added by suwondo */
		echo "<input type='hidden' name='area' id='area' value='$_SESSION[area]' />";
		list($namaarea) = mysql_fetch_row(mysql_query("select area from gl_area where id= '$_SESSION[area]'"));
		echo "<input type='text' name='txtarea' id='txtarea' size='28' readonly style='background-color:#fff;border:1px solid #999; height:16px;' value='$namaarea'  />";
		}else{
		?> 
	   <!-- Added by suwondo -->
	  <input type="hidden" name="area" id="area" value="<?php echo $row_edit['area']; ?>" />
	  <?php list($namaarea) = mysql_fetch_row(mysql_query("select area from gl_area where id = '$row_edit[area]'"));?>
	  <?php echo $namaarea; ?><?php } ?></td>
      <td bgcolor="#FFFFFF">&nbsp;</td>
      <td valign="top" bgcolor="#FFFFFF"><div align="right">Jatuh Tempo Polis : </div></td>
      <td bgcolor="#FFFFFF"><?php echo $row_edit['jthtempopolis']; ?></td>
      <td bgcolor="#FFFFFF">&nbsp;</td>
      <td valign="top" bgcolor="#FFFFFF">&nbsp;</td>
      <td colspan="2" valign="top" bgcolor="#FFFFFF">&nbsp;</td>
    </tr>
    <tr>
      <td bgcolor="#FFFFFF"><div align="right">Cabang : </div></td>
      <td bgcolor="#FFFFFF">
	  <?php
		if(!strstr($_SESSION[akses],'A-1-4')) {	
		 /* Added by suwondo */
		echo "<input type='hidden' name='cabang' id='cabang' value='$_SESSION[lokasi]' />";
		list($namalokasi) = mysql_fetch_row(mysql_query("select gudang from gl_gudang where id= '$_SESSION[lokasi]'"));
		echo "<input type='text' name='txtcabang' id='txtcabang' size='28' readonly style='background-color:#fff;border:1px solid #999; height:16px;' value='$namalokasi'  />";
		}else{
		?>
	  
	  <!-- Added by suwondo -->
	  <input type="hidden" name="cabang" id="cabang" value="<?php echo $row_edit['cabang']; ?>" />
	  <?php list($namacabang) = mysql_fetch_row(mysql_query("select gudang from gl_gudang where id = '$row_edit[cabang]'"));?>
	  <?php echo $namacabang; ?><?php } ?></td>
      <td bgcolor="#FFFFFF">&nbsp;</td>
      <td valign="top" bgcolor="#EEEEEE">KIR</td>
      <td bgcolor="#FFFFFF">&nbsp;</td>
      <td bgcolor="#FFFFFF">&nbsp;</td>
      <td valign="top" bgcolor="#FFFFFF">&nbsp;</td>
      <td colspan="2" valign="top" bgcolor="#FFFFFF">&nbsp;</td>
    </tr>
    <tr>
      <td bgcolor="#FFFFFF"><div align="right">Status Kendaraan : </div></td>
      <td bgcolor="#FFFFFF">
	   <!-- Added by suwondo -->
	  <input type="hidden" name="status" id="status" value="<?php echo $row_edit['status']; ?>" />
	  <?php list($namastatus) = mysql_fetch_row(mysql_query("select status from gl_statuskendaraan where id = '$row_edit[status]'"));?>
	  <?php echo $namastatus; ?></td>
      <td bgcolor="#FFFFFF">&nbsp;</td>
      <td valign="top" bgcolor="#FFFFFF"><div align="right">Status KIR: </div></td>
      <td bgcolor="#FFFFFF"><?php echo $row_edit['statuskir']; ?></td>
      <td bgcolor="#FFFFFF">&nbsp;</td>
      <td valign="top" bgcolor="#FFFFFF">&nbsp;</td>
      <td colspan="2" valign="top" bgcolor="#FFFFFF">&nbsp;</td>
    </tr>
    <tr>
      <td valign="top"><div align="right">Unit : </div></td>
      <td valign="top"><input name="RadioGroup" type="radio" value="1" <?php if($row_edit['unitstok']==1) { ?>checked="checked"<?php } ?> />
        Corp
        <input name="RadioGroup" type="radio" value="2" <?php if($row_edit['unitstok']==2) { ?>checked="checked"<?php } ?> />
        Retail
  <input name="RadioGroup" type="radio" value="3" <?php if($row_edit['unitstok']==3) { ?>checked="checked"<?php } ?> />
        Tugas Kantor
        <input name="RadioGroup" type="radio" value="4" <?php if($row_edit['unitstok']==4) { ?>checked="checked"<?php } ?> />
        Ops / UGC 	</td>
      <td bgcolor="#FFFFFF">&nbsp;</td>
      <td valign="top" bgcolor="#FFFFFF"><div align="right">No. KIR :</div></td>
      <td bgcolor="#FFFFFF"><?php echo $row_edit['nokir']; ?></td>
      <td bgcolor="#FFFFFF">&nbsp;</td>
      <td bgcolor="#FFFFFF">&nbsp;</td>
      <td colspan="2" bgcolor="#FFFFFF">&nbsp;</td>
    </tr>
    <tr>
      <td><div align="right">Tersedia : </div></td>
      <td><input <?php if (!(strcmp($row_edit['tersedia'],1))) {echo "checked=\"checked\"";} ?> name="ada" type="checkbox" id="ada" value="1" />
          <small>Check jika tersedia</small> </td>
      <td bgcolor="#FFFFFF">&nbsp;</td>
      <td valign="top" bgcolor="#FFFFFF"><div align="right">Jatuh Tempo KIR: </div></td>
      <td bgcolor="#FFFFFF"><?php echo $row_edit['jthtempokir']; ?>
      <input name="id" type="hidden" id="id" value="<?php echo $row_edit['id']; ?>" /></td>
      <td bgcolor="#FFFFFF">&nbsp;</td>
      <td bgcolor="#FFFFFF">&nbsp;</td>
      <td colspan="2" bgcolor="#FFFFFF">&nbsp;</td>
    </tr>
    
    <tr>
      <td align="left" bgcolor="#FFFFFF"><em>*Harus diisi</em></td>
      <td bgcolor="#FFFFFF">
          <label>
			<input type="button" name="Button" value="Tutup" onClick="javascript:window.close();">
        </label></td>
      <td bgcolor="#FFFFFF">&nbsp;</td>
      <td bgcolor="#FFFFFF">&nbsp;</td>
      <td bgcolor="#FFFFFF">&nbsp;</td>
      <td bgcolor="#FFFFFF">&nbsp;</td>
      <td bgcolor="#FFFFFF">&nbsp;</td>
      <td colspan="2" bgcolor="#FFFFFF">&nbsp;</td>
    </tr>
  </table>
</form>
